package com.learn.algorithm.designpattern.chain;

/**
 * 登录判定
 * @author wangxing
 * @version 2020/7/22 13:28 Administrator
 */
public class LoginChain extends BaseChain{
    public LoginChain(BaseChain next) {
        super(next);
    }
    RequestTemp user = new RequestTemp("wangxing","1234rewq","100");
    /**
     * 责任实现方法
     *
     * @param request
     * @return
     */
    @Override
    public boolean process(RequestTemp request) {
        System.out.println("进行责任链登录判定------");
        if(request.equalsNamePassword(user)){
            System.out.println("登录判定成功");
            if(this.getNext() == null){
                return true;
            }else{
                return this.getNext().process(request);
            }
        }
        System.out.println("登录判定失败");
        return false;
    }
}
